package com.example.springboot_manage.controller;

import com.example.springboot_manage.model.Account;
import com.example.springboot_manage.model.ShoeCategory;
import com.example.springboot_manage.repository.CategoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/merchant")
public class MecHandler {

    @RequestMapping("/admin")
    public String toAdmin(){
        return "admin";
    }

    @RequestMapping("/toShoeInfo")
    public String toShoeInfo(){
        return "merchant/shoeInfo";
    }

    @RequestMapping("/toUpdateShoeInfo")
    public String toUpdateShoeInfo(){
        return "merchant/updateShoeInfo";
    }

    @RequestMapping("/toSaveShoeInfo")
    public String toSaveShoeInfo(){
        return "merchant/addShoeInfo";
    }

    @RequestMapping("/toUpdateOrderMaster")
    public String toUpdateOrderMaster(){
        return "merchant/updateOrderMaster";
    }

    @RequestMapping("/toOrderMaster")
    public String toFindMaster(){
        return "merchant/orderMaster";
    }


    @Autowired
    private CategoryRepository categoryRepository;
    @RequestMapping("/toUpdateInfo")
    public String toUpdateInfo(HttpSession session){
        Account account = (Account) session.getAttribute("loginInfo");
        ShoeCategory category = (ShoeCategory) categoryRepository.findCategoryByType(account.getCategoryType());
        session.setAttribute("categoryInfo",category);
        ShoeCategory shoeCategory = (ShoeCategory) session.getAttribute("categoryInfo");
        return "merchant/updateInfo";
    }

    @RequestMapping("/toSpecsInfo")
    public String toFindSpecsInfo(){
        return "merchant/specsInfo";
    }

    @RequestMapping("/toUpdateSpecsInfo")
    public String toUpdateSpecsInfo(){
        return "merchant/updateSpecsInfo";
    }

    @RequestMapping("/toSaveSpecsInfo")
    public String toSaveSpecsInfo(){
        return "merchant/addSpecsInfo";
    }

    @RequestMapping("/toSpecsColor")
    public String toFindSpecsColor(){
        return "merchant/specsColor";
    }

    @RequestMapping("/toUpdateSpecsColor")
    public String toUpdateSpecsColor(){
        return "merchant/updateSpecsColor";
    }

    @RequestMapping("/toSaveSpecsColor")
    public String toSaveSpecsColor(){
        return "merchant/addSpecsColor";
    }

    @RequestMapping("/toSpecsSize")
    public String toFindSpecsSize(){
        return "merchant/specsSize";
    }

    @RequestMapping("/toUpdateSpecsSize")
    public String toUpdateSpecsSize(){
        return "merchant/updateSpecsSize";
    }

    @RequestMapping("/toSaveSpecsSize")
    public String toSaveSpecsSize(){
        return "merchant/addSpecsSize";
    }


    @RequestMapping("/toBulletin")
    public String toBulletin(){
        return "merchant/bulletin";
    }

}
